package xml;

import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;


public class LearnDom4j {
	public static Document CreatDocumentRoot(String rootName) {

		Document document = DocumentHelper.createDocument();
		document.addElement(rootName);
		return document;
	}
	
	public static void AddRootAttribute(Document doc,String attributeName,String attributeVaule)
	{
		Element root=doc.getRootElement();
		root.addAttribute(attributeName, attributeVaule);
		return ;
	}
	public static void test()
	{
		Document testdoc=CreatDocumentRoot("test");
		AddRootAttribute(testdoc,"attribute","v1");
		System.out.println(testdoc.asXML());
	}
	
	public static void main(String[] args) {
		test();
	}
}
